﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Baimasoft.Web.UI;
using HsTec.Mobile.Green.SqlServerDAL;

public partial class News_SmallClassManage : Baimasoft.Web.UI.PageManagerTop
{
    NewsBigClass MyBC = new NewsBigClass();
    NewsSmallClass MyNSC = new NewsSmallClass();

    protected void Page_Load(object sender, EventArgs e)
    {
        this.BindControlEvent();
        this.HiddenID.Value = "";
        if (!this.IsPostBack)
        {
            try
            {
                Indicator.Text = Request.QueryString["sIndicator"].ToString();
            }
            catch
            {
            }
            GridView1.Attributes.Add("BorderColor", "LightSkyBlue");
            //NewsBigDataBind();
            this.BindGridViewData();//绑定GridView,为删除服务
        }
    }

    //protected void NewsBigDataBind()
    //{
    //    ddlBigClass.DataSource = MyBC .GetNewsBigClassInfos ("");
    //    ddlBigClass.DataBind();
    //    ddlBigClass.Items.Insert(0, "全部类别");
    //    ddlBigClass.Items[0].Value = "0";
    //}



    protected override void BindGridViewData()
    {
        this.DataSource = MyNSC.GetNewsSmallClassInfos(GetSearchString());

        this.DataSource.DefaultView.Sort = this.SortString;
        GridView1.DataSource = this.DataSource.DefaultView;
        GridView1.DataBind();
    }


    protected override void Delete(string ids)
    {
        try
        {
            int iback = MyNSC .DeleteNewsSmallClassInfo (ids);
            if (iback < 1)
            {
                Baimasoft.Web.UI.Message.AlertMsg(this, "没有可删除的数据!");
                return;
            }
            else
            {
                Baimasoft.Web.UI.Message.AlertMsg(this, "删除成功!");
                return;
            }
        }
        catch
        {
            Baimasoft.Web.UI.Message.AlertMsg(this, "删除失败!");
        }
    }

    protected override string GetSearchString()
    {
        string searchStr = "(1=1)";

        if (this.txtSmallClassName.Text.Trim().Length > 0)
        {
            searchStr += " and SmallClassName like '%" + this.txtSmallClassName.Text + "%' ";
        }
        return searchStr;
    }

}



